<template>
    <div class="batch_set_supplier_form_contanier">
        <el-form ref="buyOrderForm" :rules="rules" :model="formData" label-width="100px">
            <el-form-item label="供应商" prop="supplier_sid">
                <vSelectBottom v-model="formData.supplier_sid" type="supplierDrawer"
                               @event="handleSupplierEvent" :options="supplierOptions" />
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    name: "BatchSetSupplierForm",
    data() {
        return {
            formData: {},
            rules: {
                supplier_sid: [
                    { required: true, message: "请选择供应商", trigger: "change" },
                ],
            },
            supplierOptions: {
                disabled: true,
                placeholder: '请选择供应商',
                bottomAction: {
                    permission: 'save_sys_supplier',
                    permissionUrl: '/sysSupplier',
                },
            },
        };
    },
    methods: {
        handleSupplierEvent(event) {
            const _this = this;
            if (typeof event.value !== 'undefined') {
                _this.formData = $.extend({}, _this.formData, {
                    supplier_sid: event.value,
                    supplier_display: event.data ? event.data.display : '',
                });
            }
        },
        async confirm() {
            const _this = this;
            let valid = await _this.validateForm('buyOrderForm');
            if (!valid) {
                return false;
            }
            _this.$emit('event', {
                type: 'confirm',
                value: _this.formData,
            });
            return true;
        },
    },
}
</script>

<style scoped>
.batch_set_supplier_form_contanier {
    width: 100%;
    height: 100%;
    overflow: hidden;
}
</style>